<? Phpr_View::beginBlock("head") ?>
	<link rel="stylesheet" href="modules/shop/resources/css/shop.css?<?= module_build('shop') ?>" type="text/css"/>
	<script type="text/javascript" src="modules/shop/resources/javascript/order.js?<?= module_build('shop') ?>"></script>
<? Phpr_View::endBlock() ?>

<? Phpr_View::beginBlock("view") ?>
	<ul class="breadcrumbs">
		<li><a href="<?= url('/shop/orders') ?>">Orders</a></li>
		<li><a href="<?= url('/shop/orders/preview/'.$form_record_id.'?'.uniqid()) ?>">Order Preview</a></li>
		<li><?= $this->app_page_title ?></li>
	</ul>

	<?= flash() ?>

	<? if (!isset($fatalError)): ?>
		<div class="scoreboardReport" id="order_totals">
			<? $this->renderPartial('order_totals') ?>
		</div>

		<div class="form800">
			<? if (!($lock = Db_RecordLock::lock_exists($form_model))): ?>
				<?= Phpr_Form::openTag() ?>
					<input type="hidden" name="Shop_Order[shipping_state_id]" value=""/>
					<input type="hidden" name="Shop_Order[billing_state_id]" value=""/>
					<div id="order_applied_discounts_data"><? $this->renderPartial('applied_discounts_data') ?></div>
					<div id="order_applied_discount_list"><? $this->renderPartial('applied_discounts_list') ?></div>
					<? $this->formRender() ?>

					<?= backend_ajax_button('Save', 'edit_onSave', array()) ?>
					<?= backend_ajax_button('Cancel', 'edit_onCancel') ?>

					<? if (!$form_model->deleted_at): ?>
						<?= backend_ajax_button('Mark As Deleted ', 'edit_onDeleteOrder', array('class'=>"right"), "confirm: 'Do you really want to mark this order as deleted? You will be able to restore the order if needed.'") ?>
					<? endif ?>
					
					<?= backend_ajax_button('Delete Permanently ', 'edit_onDeleteOrderPermanently', array('class'=>"right"), "confirm: 'Do you really want to DELETE this order PERMANENTLY? This action is not undoable.'") ?>
					
					<div class="clear"></div>
					<div id="tmp_site"></div>
				</form>
				<? $this->formAddLockCode() ?>
			<? else: ?>
				<? $this->renderPartial(PATH_APP.'/modules/backend/controllers/partials/_record_locked.htm', array(
					'record_name'=>'order',
					'lock'=>$lock
				)) ?>
			<? endif ?>
		</div>
	<? else: ?>
		<p><a href="<?= url('/shop/orders') ?>">Return to the order list</a></p>
	<? endif ?>
<? Phpr_View::endBlock() ?>